#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
    int n;
    cin>>n;
    vector<char> v(n+1);
    vector<int> w(n+1);
    for(int i=1;i<=n;i++)cin>>v[i];
    char c;
    int x;
    int mx=0;
    int ansi;
    for(int i=1;i<=n;i++)
    {
        cin>>w[i]>>c>>x;
        if(w[i]>mx)
        {
            mx=w[i];
            ansi=i;
        }
    }
    cout<<v[ansi];
}
signed main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int T=1;
    //cin>>T;
    while(T--)
    {
       solve();
    }
    return 0;
}